package rankingBlock

import "gitee.com/wchpub/fnsvr/funcSless"

type BlockType string

const (
	//数据块名称
	BlockName string = "ranking"
)

const (
	//档案版本号
	Key_Ver BlockType = funcSless.GAME_DATA_VERSION_KEY

	Key_LastClearRankingTime BlockType = "lastClearRankingTime" //最近一次清空排行榜的时间
)

type Data struct {
	super *funcSless.Block[BlockType]
}

// 最近一次清空排行榜的时间
func (m *Data) LastClearRankingTime() (int64, error) {
	return m.super.GetInt64(Key_LastClearRankingTime)
}

func (m *Data) SetLastClearRankingTime(v int64) {
	m.super.SetInt64(Key_LastClearRankingTime, v)
}

func (m *Data) PreLoad(keys ...BlockType) {
	m.super.PreLoad(keys...)
}

func (m *Data) GetAll() (map[string]string, error) {
	return m.super.GetAll()
}

// 获取主数据块
func GetBlock(plyData *funcSless.PlayerData) (*Data, error) {

	bk, err := funcSless.GetBlock[BlockType](plyData, BlockName)
	if err != nil {
		return nil, err
	}

	return &Data{
		super: bk,
	}, nil
}
